package com.wnxy.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wnxy.entity.Product;
import com.wnxy.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 商品表 前端控制器
 * </p>
 *
 * @author 林夕
 * @since 2023-03-11 04:45:21
 */
@RestController
@RequestMapping("/weapon")
public class ProductController {

    @Autowired
    ProductService productService;

    @RequestMapping("/topN")
    public List<Product> topN(Integer n){
        List<Product> productList = productService.topN(n);
        return productList;
    }

    @RequestMapping("/weaponByType")
    public Page<Product> weaponByType(Integer current, Integer pageSize, Integer weaponTypeId){
        Page<Product> productPage = productService.pageByType(current, pageSize, weaponTypeId);
        return productPage;
    }

    @RequestMapping("/oneWeapon")
    public Product oneWeapon(Integer weaponId){
        Product product = productService.getById(weaponId);
        return product;
    }


}

